<?php
namespace wow\controller;

class Captcha extends \gnomephp\captcha\CaptchaController{
	


	/**
	 * Override gnomewow/controller/Captcha.php index method.
	 * Better error reporting, to catch errors.
	 */
	public function index($name, $width, $height){
		error_reporting(E_ALL);
		$width = (int)$width;
		$height = (int)$height;
		if ($width > \gnomephp\captcha\CaptchaController::MAX_IMAGE_WIDTH || $height > \gnomephp\captcha\CaptchaController::MAX_IMAGE_HEIGHT) die("Max height is 600 and width 600.");
	
	
		
	
		$image = $this->getImage($name, $width, $height, $this->getCaptchaLength());
		if ($image){
			// prevent caching
			header('Expires: Tue, 08 Oct 1991 00:00:00 GMT');
			header('Cache-Control: no-cache, must-revalidate');
			
			// output the image
			header("Content-Type: image/gif");
			
			imagegif($image);
			imagedestroy($image);
		}else{
			die("Image not created! GD PHP EXTENSION MISSING ?");
		}
	}	
}